<?php
$middleware = [

];

// 遍历所有应用目录
foreach (glob(base_path('app/*/config/middleware.php')) as $file) {
    $appName = basename(dirname($file, 2));
    $appCfg  = require $file;
    if (is_array($appCfg)) {
        $middleware[$appName] = array_merge($middleware[$appName] ?? [], $appCfg);
    }
}

return $middleware;